package demo1;

public class Test {

    public static void eat(Animal animal) { //参数类型为父类，可形成多态
        animal.eat(); //子类重写了eat方法
    }

    public static void fly(IFlying f) {
        f.fly();
    }

    public static void swim(ISwimming s){
        s.swimming();
    }
    public static void run(IRunning r) {
        r.running();
    }

    public static void main(String[] args) {
        Dog d=new Dog("小狗",3);
        Cat c=new Cat("小猫",2);
        Bird b=new Bird("小鸟",1);

        fly(b);
        System.out.println("==============");
        swim(d);
        System.out.println("==============");
        run(d);
        run(c);
        run(b);
    }

    public static void main1(String[] args) {
        Dog d=new Dog("欢欢",10);
        Cat c=new Cat("嘻嘻",7);
        eat(d);
        eat(c);
    }
}
